import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import { univerPlugin } from "@univerjs/vite-plugin";
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    univerPlugin(),
    vue(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    port: 5373,//端口号
    host: true,//ip地址 或 '0.0.0.0' 或 "locallhost"
    open: false, //启动后是否自动打开浏览器r
    https: false, // 是否开启 https
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:10420',  //你要跨域访问的网址
        port: 10420,
        changeOrigin: true,   // 允许跨域
        rewrite: (path) => path.replace(/^\/api/, '') // 重写路径把路径变成空字符
      }
    }
  },
  
  
})
